local guzhen = fk.CreateSkill {
  name = "kl__guzhen",
}

guzhen:addEffect(fk.TargetSpecifying, {
  can_trigger = function (self, event, target, player, data)
    local mark = player:getTableMark("@kl__guzhen-turn") or {}
    if data.to == player and player:hasSkill(guzhen.name) and #mark ~= 3 then
      if data.card.type == Card.TypeBasic then
        return not table.contains(mark, "基")
      elseif data.card.type == Card.TypeTrick then
        return not table.contains(mark, "锦")
      elseif data.card.type == Card.TypeEquip then
        return not table.contains(mark, "装")
      end
    end
  end,
  on_cost = function (self, event, target, player, data)
    return player.room:askToSkillInvoke(player,{
      skill_name = guzhen.name,
      prompt = "#kl__guzhen-invoke:::"..data.card:toLogString(),
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local mark = player:getTableMark("@kl__guzhen-turn") or {}
    if data.card.type == Card.TypeBasic then
      room:addTableMarkIfNeed(player, "@kl__guzhen-turn", "基")
    elseif data.card.type == Card.TypeTrick then
      room:addTableMarkIfNeed(player, "@kl__guzhen-turn", "锦")
    elseif data.card.type == Card.TypeEquip then
      room:addTableMarkIfNeed(player, "@kl__guzhen-turn", "装")
    end
    local names = player:getTableMark("@$kl__guzhen") or {}
    table.insertIfNeed(names, data.card.name)
    room:setPlayerMark(player, "@$kl__guzhen", names)
    player:drawCards(1, guzhen.name)
  end,
})


return guzhen
